#include <stdio.h>
#include <stdlib.h>
#include "win_nt.h"
#include "msg_core.h"
#include "defines.h"
#include "UILabel.h"
#include "UIEdit.h"
#include "UICheckBox.h"
#include "UIComboBox.h"
#include "UIScrollContainer.h"

void ui_test(DuiWinManager *mgr){
    auto pRoot = (UILabel*)mgr->pRoot;
    auto pLable = new UILabel(pRoot);
    pLable->setRect(DuiRect{50, 30, 200, 300});
    pLable->setText(u8"Hello 中国😀, 我们有365个民族，还有广阔的海洋和陆地! nice to meet you!");
    pLable->setColor(DuiColor{0, 0, 0, 155});
    pLable->setFontWeight(600);
    pLable->setBackgroundColor(DuiColor{0, 100, 0, 150});
    pLable->setBorderRadius(10);
    pLable->setBorderWidth(4);
    pLable->setBorderColor(DuiColor{0, 255, 255, 150});
    pLable->setBorderLineStyle(DUI_LINE_STYLE_DASH);
    pLable->setPadding(DuiCorner{10, 10, 10, 10});
    pLable->setMargin(DuiCorner{10, 10, 10, 10});
    pLable->setShadowColor(DuiColor{0, 0, 0, 20});
    pLable->setShadowOffset(DuiPoint{10, 10});
    pLable->setCursor(DUI_CURSOR_STYLE_HAND);

    auto btn = new UILabel(pRoot);
    btn->setRect(DuiRect{210, 10, 128, 128});
    btn->setText(u8"Button");
    btn->setColor(DuiColor{255, 0, 0, 255});
    btn->setBackgroundColor(DuiColor{100, 200, 0, 100});
    btn->setBackgroundImage("logo.png");
    btn->setCursor(DUI_CURSOR_STYLE_NO);

    // edit
    auto edit = new UIEdit(pRoot);
    edit->setRect(DuiRect{250, 150, 200, 128});
    edit->setText(u8"Hello中国\t😀, 我们有365 个民族，还有广阔的 海洋和陆地! nice to meet you!");
    edit->setColor(DuiColor{0, 0, 0, 255});
    edit->setBackgroundColor(DuiColor{255, 255, 255, 255});
    edit->setCursor(DUI_CURSOR_STYLE_IBEAM);

    // checkbox
    auto checkbox = new UICheckBox(pRoot);
    checkbox->setRect(DuiRect{410, 10, 120, 40});

    // combobox
    auto combobox = new UIComboBox(pRoot);
    combobox->setRect(DuiRect{410, 60, 120, 40});
    combobox->setBorderRadius(8);

    // scroll container
    auto scroll = new UIScrollContainer(pRoot);
    scroll->setRect(DuiRect{410, 110, 220, 240});
    scroll->setScrollBarShowX(true);
    scroll->setScrollViewport(DuiRect{0, 0, 2020, 1000});
}

int main(int argc, char **argv)
{
    printf("hello,world!\r\n");
    DuiWinManager mgr;
    shell_mgr_init(&mgr);
    if (shell_init(&mgr, 800, 600, u8"Hello 中国😀", DUI_WIN_FLAG_NONE ))
    {
        printf("win: %d\r\n", mgr.hWin);
        shell_win_set_transparent(&mgr, DuiColor{0,0,0,200}, false);
        shell_win_set_icon(&mgr, "logo.ico");
        ui_test(&mgr);
        shell_loop(&mgr);
    }
    return 0;
}